package com.byzk.p2p.admin.borrow.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.byzk.p2p.admin.base.util.PageInfo;
import com.byzk.p2p.admin.borrow.dao.ProductDao;
import com.byzk.p2p.admin.borrow.dto.Product;

/**
 * 产品相关service
 * @author Administrator
 *
 */
@Service
public class ProductService {
	
	@Autowired
	private ProductDao productDao ;
	
	/**
	 * 查询产品列表
	 * @return
	 */
	public PageInfo<Product> productList(Product product){
		int count = productDao.count(product);
		List<Product> productVo = productDao.list(product);
		PageInfo<Product> page=new PageInfo<Product>(count,product.getIndex() ,product.getLimit());
		page.setPageList(productVo);
		return page;
	}
 
	public int saveOrUpadte(Product product){
		int temp ;
		if(product.getId() == null){
			temp = productDao.insert(product);
		}else{
			temp = productDao.update(product);
		}
		return temp;
	}
	
	public Product selectById(Integer id){
		return productDao.getById(id);
	}
	
	public List<Product> productList(){
		return productDao.productList();
	}
	
	public Integer delete(Integer id){
		return productDao.delete(id);
	}
}
